package com.dyava.commons.validate;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class ValidateLocalDate extends Validate<LocalDate,ValidateLocalDate> {
	DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");

	public ValidateLocalDate(LocalDate value, String name) {
		this.value = value;
		this.name = name;
	}

	public ValidateLocalDate gt(LocalDate value){
		if (checkNull()) return this;
		if(this.value.compareTo(value)>0){
			return this;
		}
		throw new ValidateFastException(name+"必须大于"+ df.format(value));
	}

	public ValidateLocalDate lt(LocalDate value){
		if (checkNull()) return this;
		if(this.value.compareTo(value)<0){
			return this;
		}
		throw new ValidateFastException(name+"必须小于"+ df.format(value));
	}

	public ValidateLocalDate ge(LocalDate value){
		if (checkNull()) return this;
		if(this.value.compareTo(value)>=0){
			return this;
		}
		throw new ValidateFastException(name+"必须大于等于"+ df.format(value));
	}

	public ValidateLocalDate le(LocalDate value){
		if (checkNull()) return this;
		if(this.value.compareTo(value)<=0){
			return this;
		}
		throw new ValidateFastException(name+"必须小于等于"+ df.format(value));
	}





}
